<?php
    ob_start();
    session_set_cookie_params(0, NULL, NULL, NULL, TRUE); //http only cookie
    session_start();

    $page_title = "Dobavi novina | Box";
    require "../includes/header_snimki.php";

//PROVERKA DALI IMA VALIDNA SESIQ I INCLUDE NA MAIN PANELA
    if(isset($_SESSION['isLogged']) && $_SESSION['isLogged'] == true) {


        include "../includes/common.php";
        include "create_new.php";
    }
    else {

        if($_POST) {
            $formUser = htmlspecialchars(trim($_POST['formUser']));
            $formPass = htmlspecialchars(trim($_POST['formPass']));

            //VALIDATION FOR CORRECT USERNAME/PASSWORD
            if($formUser == 'box' && $formPass == 'Mefata20') {
                $_SESSION['isLogged'] = true;
                header('Location: index.php');
                exit;
            }
            else { echo '</br></br></br>Грешни потребителски данни.</br>'; }
        }

        ?>

        <br/><br/><br/><p style="font-size: 20px; text-align: center; color: red;">Вход -
            Администраторски панел за добавяне, изтриване и променяне на новини</p>

        <form method="POST" action="index.php"><br/>
            <span style="width: 150px; display: inline-block;">Потребителско име:</span><input type="text" name="formUser"/></br>
            <span style="width: 150px; display: inline-block;">Парола:</span><input type="password" name="formPass"/></br>
            <input type="submit" value="Влез в системата"/>
        </form>
        <br/><br/><br/><br/><br/><br/><br/><br/><br/>

    <?php
    }

    require "../includes/footer_snimki.php";
?>